package com.woniuxy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.mapper.AdvertisementMapper;
import com.woniuxy.pojo.Advertisement;
import com.woniuxy.pojo.dto.AdvertisementDto;
import com.woniuxy.service.AdvertisementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Xi'ao'M'ing
* @description 针对表【t_advertisement(广告表)】的数据库操作Service实现
* @createDate 2025-06-07 16:38:15
*/
@Service
public class AdvertisementServiceImpl extends ServiceImpl<AdvertisementMapper, Advertisement>
    implements AdvertisementService {
    @Autowired
    private AdvertisementMapper advertisementMapper;

    @Override
    public Page<Advertisement> getAdListData(Integer pageNum, Integer pageSize, AdvertisementDto dto) {
        LambdaQueryWrapper<Advertisement> wrapper = new LambdaQueryWrapper<>();
        if (dto!=null){
            if (dto.getAdName()!=null&& !dto.getAdName().equals("")){
                wrapper.like(Advertisement::getAdName,dto.getAdName());
            }
            if (dto.getPosition()!=null&& !dto.getPosition().equals("")){
                wrapper.like(Advertisement::getPosition,dto.getPosition());
            }
            if (dto.getStatus()!=null&&dto.getStatus()!=-1){
                wrapper.eq(Advertisement::getStatus,dto.getStatus());
            }
        }
        Page<Advertisement> page = new Page<>(pageNum,pageSize);
        page = advertisementMapper.selectPage(page,wrapper);
        return page;
    }


}




